package com.arch.dev.client.view.chart;

import pl.rmalinowski.gwt2swf.client.ui.SWFSettings;
import pl.rmalinowski.gwt2swf.client.ui.SWFWidget;
import pl.rmalinowski.gwt2swf.client.utils.PlayerVersion;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class FlexGraphView extends Composite {

	private static FlexGraphViewUiBinder uiBinder = GWT
			.create(FlexGraphViewUiBinder.class);

	interface FlexGraphViewUiBinder extends UiBinder<Widget, FlexGraphView> {
	}

	public FlexGraphView(String flexFileName, int height) {
		initWidget(uiBinder.createAndBindUi(this));
		initFlexComponent(flexFileName, height);
	}

	@UiField
	DockPanel verticalPanel;
	
	private void initFlexComponent(String flexFileName, int height){
			
		SWFWidget swfWidget = new SWFWidget(flexFileName,"100%", "" + height + "px", configureCommonSettings());
		swfWidget.addParam("quality","high"); 
	//	swfWidget.addParam("bgcolor","#869ca7"); 
		swfWidget.addParam("allowScriptAccess","always"); 
		//swfWidget.addParam("wmode", "transparent");
	//	swfWidget.setHeight("100%");
	//	swfWidget.setWidth("100%");		
		//verticalPanel.setWidget(swfWidget);
		verticalPanel.add(swfWidget,DockPanel.CENTER);
		
	}
	
	private SWFSettings configureCommonSettings(){
		
		SWFSettings commonSettings = new SWFSettings();
		PlayerVersion minPlayerVersion = new PlayerVersion(9, 0, 0);
		commonSettings.setMinPlayerVersion(minPlayerVersion);
		commonSettings.setInnerDivTextForFlashPlayerNotFound("Here should be a my.swf movieclip.");
		return commonSettings;
	}

}
